using System.Utility.System;

namespace System.Utility.Security
{
	public class UserInfo
	{
		public int RoleId
		{
			get;
			set;
		}

		public string UserId
		{
			get;
			set;
		}

		public string UserName
		{
			get;
			set;
		}

		public UserInfo()
		{
			UserId = string.Empty;
			UserName = string.Empty;
			RoleId = 0;
		}

		public UserInfo(string userId, string userName, int roleId) : this()
		{
			UserId = userId;
			UserName = userName;
			RoleId = roleId;
		}

		public UserInfo(string data) : this()
		{
			if (!string.IsNullOrEmpty(data))
			{
				string[] strArrays = data.Split(new char[] { '|' });
				if ((int)strArrays.Length >= 3)
				{
					UserId = strArrays[0];
					UserName = strArrays[1];
					RoleId = TypeExtension.ToSafeInt(strArrays[2]);
				}
			}
		}

		public override string ToString()
		{
			object[] userId = new object[] { UserId, "|", UserName, "|", RoleId };
			return string.Concat(userId);
		}
	}
}